<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .root{
        width: 200px;
        height: 200px;
        background-color: #635f5f;
    }
    .box{
        width: 100px;
        height: 100px;
        background-color: red;
    }
</style>
<body>
    <button id="btn">按钮</button>
    <a href="https://www.baidu.com" id="bai">百度</a>
    <div class="root" id="root">
        <div class="box" id="box"></div>
    </div>
    <script>
        var btn = document.getElementById("btn");
        var bai = document.getElementById("bai");
        var root = document.getElementById("root");
        var box = document.getElementById("box");
        btn.onclick = function(e){
            //常用的属性：
            event.target.innerHTML="点击之后"
            console.log(event.type);
            
            bai.onclick = function(e){
                //preventDefault()阻止了默认事件
                e.preventDefault();
                console.log("点击了");
            }
        }

        root.onclick = function(){
            console.log("root");
        }
        box.onclick = function(e){
            //阻止事件冒泡）
            e.stopPropagation();
            console.log("box");
        }
    </script>
</body>
</html>